package com.eedi.org.healthinfo.dal.mapper;

import com.eedi.framework.common.pojo.PageResult;
import com.eedi.framework.mybatis.core.mapper.BaseMapperX;
import com.eedi.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.eedi.org.healthinfo.controller.vo.OrgHealthInfoPageReqVO;
import com.eedi.org.healthinfo.dal.dataobject.OrgHealthInfoDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;


/**
 * 健康资讯 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface OrgHealthInfoMapper extends BaseMapperX<OrgHealthInfoDO> {

    default PageResult<OrgHealthInfoDO> selectPage(OrgHealthInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrgHealthInfoDO>()
                .eqIfPresent(OrgHealthInfoDO::getOrgHealthInfoGroupId, reqVO.getOrgHealthInfoGroupId())
                .eqIfPresent(OrgHealthInfoDO::getOrgTitle, reqVO.getOrgTitle())
                .eqIfPresent(OrgHealthInfoDO::getOrgPublishStatus, reqVO.getOrgPublishStatus())
                .eqIfPresent(OrgHealthInfoDO::getOrgHomeRecommend, reqVO.getOrgHomeRecommend())
                .eqIfPresent(OrgHealthInfoDO::getOrgColumnRecommend, reqVO.getOrgColumnRecommend())
                .betweenIfPresent(OrgHealthInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OrgHealthInfoDO::getId));
    }

    default List<OrgHealthInfoDO> selectByGroupId(String orgHealthInfoGroupId) {
        return selectList(OrgHealthInfoDO::getOrgHealthInfoGroupId, orgHealthInfoGroupId);
    }

}
